package com.kfm.shop;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.util.Random;

@SpringBootApplication
@EnableDiscoveryClient // 服务发现
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
        // 导入依赖
        // 配置文件 8888/prod/find/1 http://localhost:8080/find/1
            // routes
            // id: name uri: http://localhost:8080 predicate: - Path=/prod/  filters: - StripPrefix=1
            // id uri predicates: - Path return true 才会到 uri进行访问
        // 进阶 注册网关服务 nacos 依赖 Ribbon 负载均衡
        // 启动类添加 EnableDiscoveryClient 服务发现
        // uri: lb://服务名称  predicate: - Path=/prod/  filters: - StripPrefix=1
        // 更简洁的写法
        // product-service product order-service user-service
        // localhost:8888/product-service/find/1 --> localhost:8080/product/find/1
        // 动态注册路由 默认匹配的路径是 服务名称
        // discovery: locator: enabled: true filters: - PrefixPath=/product - StripPrefix=1
        // System.out.println(new Random().nextInt(18) + 1);
    }
}
